package com.seventh.parkingrent.controller;

import com.seventh.parkingrent.common.Result;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

@RestController
@CrossOrigin("*")
public class UploadController {
    @PostMapping("upload")
    public Result upload(MultipartFile file) throws IOException {
        System.out.println("执行上传照片操作");

        file.transferTo(new File("D:\\idea-workspace\\parking-rent-for-user-serves\\src\\main\\resources\\static\\images" + file.getOriginalFilename()));
        return Result.success("D:\\idea-workspace\\parking-rent-for-user-serves\\src\\main\\resources\\static\\images"+file.getOriginalFilename());
    }
}
